"""
count = 1
while count <= 5:
    print(f"count={count}")
    count += 1


x = 1
sum = 0
while x <= 100:
    sum += x
    x += 1
print(f"sum={sum}")


# break跳出while循环

while 1 == 1:
    user_input = input("请输入一个正数")
    try:
        if user_input.isdigit() and int(user_input) > 0:
            print(f"输入{user_input}的数字跳出")
            break
        else:
            print(f"输入{user_input}的数字无效,请继续输入")
            continue
    except SyntaxError as e:
        raise ValueError(f"数字异常{e}")


fruits = ["苹果", "香蕉", "荔枝"]
index = 0
while index < len(fruits):
    print(fruits[index])
    index += 1


# while循环可以有一个else子句
count = 1
while count <= 3:
    print(f"循环第 {count} 次")
    count += 1
else:
    print("循环正常结束（不是通过break退出）")



import random

secret_number = random.randint(1, 20)  # 生成1-100的随机正数

max_number = 10

attempts = 0

print("猜数字游戏，目前生成了一个1-100的随机正数")
while secret_number < max_number:
    guess = int(input("请输入你的猜测"))
    attempts += 1
    if guess < secret_number:
        print("太小了")
    elif guess > secret_number:
        print("太大了")
    else:
        print(f"恭喜！你在第 {attempts} 次猜对了！")
        break
else:
    print(f"游戏结束！正确答案是 {secret_number}")





def show_menu():
    print("\n=== 菜单系统 ===")
    print("1. 查看信息")
    print("2. 修改信息")
    print("3. 退出系统")


while True:
    show_menu()
    choice = input("请选择操作（1-3）：")

    if choice == "1":
        print("显示信息...")
    elif choice == "2":
        print("修改信息...")
    elif choice == "3":
        print("感谢使用，再见！")
        break
    else:
        print("无效选择，请重新输入！")

"""

xx = 1
while xx < 5:
    print(f"xx=={xx}")
    if xx == 4:
        break
    else:
        xx += 1

else:
    print(f"xxxxxx=={xx}")

print("f最终xx的值为={xx}")
